import java.util.Arrays;

public class Solution2373 {
    public int[][] largestLocal(int[][] grid) {
        int[][] ans=new int[grid.length-2][grid[0].length-2];
        for (int i=0;i<ans.length;i++){
            for (int j=0;j<ans[0].length;j++){
                for (int k=0;k<3;k++){
                    for (int p=0;p<3;p++){
                        ans[i][j]=Math.max(ans[i][j],grid[i+k][j+p]);
                    }
                }
            }
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(Arrays.deepToString(new Solution2373().largestLocal(new int[][]{{9, 9, 8, 1}, {5, 6, 2, 6}, {8, 2, 6, 4}, {6, 2, 2, 2}})));
    }
}
